//
//  UITextField+HKExtension.h
//  HKProject
//
//  Created by 胡锦涛 on 2018/8/28.
//  Copyright © 2018年 胡锦涛. All rights reserved.
/*
 Xcode11访问 _placeholderLabel crash
 [textField setValue:UIColorWithRGB(0x9c9c9d) forKeyPath:@"_placeholderLabel.textColor"]
 Xcode11开始会crash报错私有属性不允许访问：
 解决方案：
 ①推荐 使用属性UITextField的attributedPlaceholder属性,需要注意每个设置textFiled.placeHolder的地方都需要调用。
 - (void)setPlaceHolderText:(NSString *)placeHolderText{
     NSMutableAttributedString *attPlaceHolder = [[NSMutableAttributedString alloc] initWithString:placeHolderText];
     [attPlaceHolder addAttributes:@{NSForegroundColorAttributeName:RGB(0x9c9c9d)} range:NSMakeRange(0, placeHolderText.length)];
     _searchTextField.attributedPlaceholder = attPlaceHolder;
 }
 ②简单的修改方式，把下划线去掉就可以:
 UILabel *placeHolderLabel = [_textfield valueForKeyPath:@"placeholderLabel"];
 placeHolderLabel.textColor = RGB(0x9c9c9d);
 ③runtime:
 Ivar ivar =  class_getInstanceVariable([UITextField class], "_placeholderLabel");
 UILabel *placeholderLabel = object_getIvar(textField, ivar);
 placeholderLabel.textColor = RGB(0x9c9c9d);
 
 */

#import <UIKit/UIKit.h>

@interface UITextField (HKExtension)

///placeholderColor
@property UIColor *hk_placeholderColor;

///placeHolderText
- (void)hk_placeHolderText:(NSString *)placeHolderText;

///UITextField添加LeftView距离
- (void)hk_addLeftDistance:(CGFloat)distance;

///UITextField右上角添加完成按钮
- (void)hk_addCompleteAccessoryViewWithTarget:(id)target Selector:(SEL)sel;

///setTextFiedMaxLimit设置textField最大限制 kMAXTAGLIMIT withString:text
- (void)hk_setMaxLimit:(NSInteger)limit withString:(NSString *)str;

///设置TextField赋值显示
- (void)hk_setMaxTextLimit:(NSInteger)limit withString:(NSMutableString *)string;
@end

@interface UITextView (HKExtension)

///UITextField右上角添加完成按钮
- (void)hk_addCompleteAccessoryViewWithTarget:(id)target Selector:(SEL)sel;

///setTextViewMaxLimit setTextFiedMaxLimit:kMAXTAGLIMIT withString:text
- (void)hk_setMaxLimit:(NSInteger)limit withString:(NSString *)str;

///设置TextView赋值显示
- (void)hk_setMaxTextLimit:(NSInteger)limit withString:(NSMutableString *)string;
@end
